<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加/修改供应商信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
</head>

<body>
    <div id="app" v-cloak>
        <div class="add">
            <div class="header">
                <span>{{(action == 'Add'?'添加':'修改')}}供应商信息</span>
            </div>
            <div class="main" style="padding: 0 15px;">
                <!-- 配置属性, 目前仅支持 单主表 多子表 结构 -->
                <div id="form" :data-options="JSON.stringify({'tableName':'supplier_info','formName':'dataForm' ,'primaryKey':'Supplier_SerialNumber'})">
                    <!-- 子表 -->
                    <div :data-options="JSON.stringify({'tableName':'supplier_brand','formName':'childDataForm', 'parentTableName':'supplier_info'})"></div>
                </div>
                <div class="table_titel">
                    <div class="titel">供应商信息</div>
                </div>
                <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">供应商名称</div>
                            </template>
                            <el-form-item prop="Supplier_Name" :rules="[{ required: true, message: '供应商名称', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Supplier_Name" placeholder="请输入供应商名称" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>	
                        
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">纳税识别号</div>
                            </template>
                            <el-form-item prop="Tax_Number" :rules="[{ required: true, message: '请输入纳税识别号', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Tax_Number" placeholder="请输入纳税识别号" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">所属企业</div>
                            </template>
                            <el-form-item prop="Enterprise_Info_SerialNumber" :rules="[{ required: true, message: '请选择所属企业', trigger: 'change' }]">
                                <el-select v-model.trim="dataForm.Enterprise_Info_SerialNumber" placeholder="请选择所属企业" filterable style="width: 100%" clearable>
                                    <el-option v-for="(enterpriseItem, enterpriseIndex) in enterpriseList" :key="enterpriseIndex" 
                                        :label="enterpriseItem.Enterprise_Name || enterpriseItem.Enterprise_Info_SerialNumber" 
                                        :value="enterpriseItem.Enterprise_Info_SerialNumber"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item :span="2">
                            <template slot="label">
                                <div class="cell-item required">地址（省-市-区）</div>
                            </template>
                            <el-form-item prop="CountyNumber" :rules="[{ required: true, message: '请选择地址', trigger: 'change' }]">
                                <el-cascader @change="changeCity" v-model.trim="dataForm.CountyNumber" filterable
                                    :props="{label:'name',value:'code',emitPath:false}" :options="city" clearable placeholder="请选择地址"
                                    style="width: 100%;"></el-cascader>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">省行政区编码</div>
                            </template>
                            <el-form-item prop="ProvinceNumber" :rules="[{ required: true, message: '请输入省行政区编码', trigger: 'blur' }]">
                                <el-input :disabled="!dataForm.CountyNumber" v-model.trim="dataForm.ProvinceNumber" placeholder="请输入省行政区编码" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">市行政区编码</div>
                            </template>
                            <el-form-item prop="CityNumber" :rules="[{ required: true, message: '请输入市行政区编码', trigger: 'blur' }]">
                                <el-input :disabled="!dataForm.CountyNumber" v-model.trim="dataForm.CityNumber" placeholder="请输入市行政区编码" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">区行政区编码</div>
                            </template>
                            <el-form-item prop="CountyNumber" :rules="[{ required: true, message: '请输入区行政区编码', trigger: 'blur' }]">
                                <el-input :disabled="!dataForm.CountyNumber" v-model.trim="dataForm.CountyNumber" placeholder="请输入区行政区编码" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>

                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">注册详细地址</div>
                            </template>
                            <el-form-item prop="Detailed_Address" :rules="[{ required: true, message: '请输入详细地址', trigger: 'blur' }]">
                                <el-input :disabled="!dataForm.CountyNumber" v-model.trim="dataForm.Detailed_Address"
                                    placeholder="请输入详细地址" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                    </el-descriptions>
                </el-form>

                <div class="table_titel">
                    <div class="titel">供应商品牌信息</div>
                    <div class="operation">
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>

                <el-form :model="{childDataForm:childDataForm.filter(i=>!i.Row_Status || i.Row_Status != '1')}" ref="childForm" 
                    :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border 
                        v-for="(item,index) in childDataForm.filter(i=>!i.Row_Status || i.Row_Status != '1')" :key="index">
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">品牌流水号</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Brand_SerialNumber`" :rules="[{ required: true, message: '请选择品牌', trigger: 'change' }]">
                                <el-select v-model.trim="item.Brand_SerialNumber" placeholder="请选择品牌" filterable style="width: 100%" clearable>
                                    <el-option v-for="(brandItem, brandIndex) in brandList" :key="brandIndex" 
                                        :label="brandItem.Brand_Name || brandItem.Brand_SerialNumber" 
                                        :value="brandItem.Brand_SerialNumber"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-descriptions-item>
                    </el-descriptions>
                    <div v-if="childDataForm.filter(i=>!i.Row_Status || i.Row_Status != '1').length === 0" style="padding: 20px; text-align: center; color: #999;">
                        暂无品牌信息，请点击上方"新增"按钮添加
                    </div>
                </el-form>
            </div>
            <div class="footer">
                <el-button size="medium" @click="handleBack">返回</el-button>
                <el-button size="medium" type="primary" plain @click="handleSubmit" :loading="loading">提交</el-button>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../utils/components.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="../../../utils/http.js"></script>
    <script type="text/javascript" src="js/add.js"></script>
</body>

</html>